/**
 * Created by sun on 2016/8/4.
 */
define(function (require) {
    var app = require('/../js/app');
    require('ui-table');

    require('angular-ueditor');
    require('upload');
    require('ZeroClipboard');


    app.useModule("ui.table");
    app.useModule("ng.ueditor");
    app.useModule("ngFileUpload");

    var datepicker = require('datepicker');
    var toastr =require('toastr');

    app.controller('searchCtrl', ['$scope','$http','$filter','Upload',function ($scope, $http,$filter,Upload){
        datepicker($scope);
        $scope.ctrlScope=$scope;
        $scope.ctrlScope.message={};
        $scope.ctrlScope.message_2={};
        $scope.ctrlScope.car={};
        $scope.ctrlScope.training={};
        $scope.ctrlScope.CarMall={};
        $scope.ctrlScope.item={};
        $scope.ctrlScope.repay={};
        $scope.imgs = [];
        $scope.score={};
        $scope.ctrlScope.first={};

        $scope.isEdit=false;

        $scope.orderParams1={};
        $scope.assetOrderParams1={};

        $scope.select2Options = {
            minimumResultsForSearch: Infinity //不出现搜索框
        };
        $scope.selectOptions = {
            allowClear: false,
            language : 'zh-CN',
        };

        $scope.getHours= function () {
            var hours=[];
            for(var i=0;i<24;i++){
                if(i<10){
                    i="0"+i
                }
                hours.push(i)
            }
            return hours;
        };
        $scope.getMins= function () {
            var mins=[];
            for(var i=0;i<60;i++){
                if(i<10){
                    i="0"+i
                }
                mins.push(i)
            }
            return mins;
        };

        //查询订单
        $scope.openStatus2Modal= function (bidId) {
            $scope.add={};
            $scope.add.bidId=bidId;
            $scope.status2Modal = !$scope.status2Modal;
            $http({
                method: 'POST',
                url: "/admin/order/bidSearch",
                data:{bidId:bidId}
            }).success(function(data) {
                if(data.respSubCode=='000000'){
                    if(data.bidStatus == 'W'){
                        $scope.add.respSubdes='等待中';
                        $scope.add.status='W';
                    }else if(data.bidStatus == 'II'){
                        $scope.add.respSubdes='投资中';
                        $scope.add.status='S';
                        $scope.add.bidStatus=data.bidStatus ;
                        $scope.add.bankAuditStatus=data.bankAuditStatus;
                        $scope.firstStatus= function () {
                            $http({
                                method: 'POST',
                                url: "/pay/notice/createBid",
                                data:$scope.add
                            }).success(function(data) {
                                $scope.add={};
                                if(data.result=='success'){
                                    toastr.success('补单成功');
                                    $scope.status2Modal = !$scope.status2Modal;
                                    $scope.orderParams.reload();
                                }else{
                                    toastr.error('补单失败');
                                    $scope.status2Modal = !$scope.status2Modal;
                                }

                            }).error(function(data) {});
                        }
                    }else if(data.bidStatus == 'GI'){
                        $scope.add.respSubdes='放款中';
                        $scope.add.status='GI';
                    }else if(data.bidStatus == 'GD'){
                        $scope.add.respSubdes='已放款';
                        $scope.add.status='GD';
                    }else if(data.bidStatus == 'CI'){
                        $scope.add.respSubdes='流标中';
                        $scope.add.status='CI';
                    }else if(data.bidStatus == 'CD'){
                        $scope.add.respSubdes='已流标';
                        $scope.add.status='CD';
                    }
                }else if(data.respSubCode=='200103'){
                    $scope.add.respSubdes='商户流水已存在'
                    $scope.add.status='F';
                }else if(data.respSubCode=='100000'){
                    $scope.add.respSubdes='参数校验失败'
                    $scope.add.status='F';
                }else if(data.respSubCode=='200004'){
                    $scope.add.respSubdes='标的不存在';
                    $scope.add.status='F';
                }else{
                    $scope.add.respSubdes='服务器繁忙'
                    $scope.add.status='F';
                }



            }).error(function(data) {});
        };

        $scope.openStatus23Modal= function (bidId) {
            $scope.add={};
            $scope.add.bidId=bidId;
            $scope.status23Modal = !$scope.status23Modal;
            $http({
                method: 'POST',
                url: "/admin/order/bidSearch",
                data:{bidId:bidId}
            }).success(function(data) {
                if(data.respSubCode=='000000'){
                    if(data.bidStatus == 'W'){
                        $scope.add.respSubdes='等待中';
                        $scope.add.status='W';
                    }else if(data.bidStatus == 'II'){
                        $scope.add.respSubdes='投资中';
                        $scope.add.status='II';
                    }else if(data.bidStatus == 'GI'){
                        $scope.add.respSubdes='放款中';
                        $scope.add.status='GI';
                    }else if(data.bidStatus == 'GD'){
                        $scope.add.respSubdes='已放款';
                        $scope.add.status='S';
                        $scope.secondStatus= function () {
                            $scope.add.bizType='5001';
                            $http({
                                method: 'POST',
                                url: "/pay/notice/bidGrant",
                                data:$scope.add
                            }).success(function(data) {
                                $scope.add={};
                                if(data.result=='success'){
                                    toastr.success('补单成功');
                                    $scope.checkModal = !$scope.checkModal;
                                    $scope.status23Modal = !$scope.status23Modal;
                                    $scope.orderParams.reload();
                                }else{
                                    toastr.error('补单失败');
                                    $scope.status23Modal = !$scope.status23Modal;
                                }

                            }).error(function(data) {});
                        }
                    }else if(data.bidStatus == 'CI'){
                        $scope.add.respSubdes='流标中';
                        $scope.add.status='CI';
                    }else if(data.bidStatus == 'CD'){
                        $scope.add.respSubdes='已流标';
                        $scope.add.status='CD';
                    }
                }else if(data.respSubCode=='200103'){
                    $scope.add.respSubdes='商户流水已存在'
                    $scope.add.status='F';
                }else if(data.respSubCode=='100000'){
                    $scope.add.respSubdes='参数校验失败'
                    $scope.add.status='F';
                }else if(data.respSubCode=='200004'){
                    $scope.add.respSubdes='标的不存在';
                    $scope.add.status='F';
                }else{
                    $scope.add.respSubdes='服务器繁忙'
                    $scope.add.status='F';
                }



            }).error(function(data) {});
        };
        //导出
        $scope.download=function(){
            var params={};
            params=$scope.ctrlScope.itemsearch;
            $http.post("/admin/item/excel/item",params)
                .success(function (data){
                    if(data.result=="success"){
                        window.open(data.file);
                    }else{
                        toastr.error("导出失败");
                    }
                }).error(function(data){
                });
        };

        //导出投资信息
        $scope.recordDownload=function(){
            var params={id: $scope.downloadId};
            $http.post("/admin/item/excel/invest",params)
                .success(function (data){
                    if(data.result=="success"){
                        window.open(data.file);
                    }else{
                        toastr.error("导出失败");
                    }
                }).error(function(data){
                });
        };


        //弹框内容初始化
        $scope.modelInit=function(){
            $scope.imgs = [];
            $scope.score={};
            $scope.imgs1=[];
            $scope.imgs2=[];
            $scope.imgs3=[];
            $scope.imgs4=[];
            $scope.imgs5=[];
            $scope.imgs6=[];
            $scope.imgs7=[];
            $scope.imgs8=[];
            $scope.imgs21=[];
            $scope.imgs22=[];
            $scope.imgs23=[];
            $scope.imgs24=[];
            $scope.imgs25=[];
            $scope.imgs26=[];
            $scope.imgs27=[];
            $scope.imgs28=[];
            $scope.imgs29=[];
            $scope.imgs30=[];
            $scope.imgs41=[];
            $scope.imgs42=[];
            $scope.imgs43=[];
            $scope.imgs44=[];
            $scope.imgs45=[];
            $scope.imgs46=[];
            $scope.imgs47=[];
            $scope.imgs48=[];
            $scope.imgs61=[];
            $scope.imgs62=[];
            $scope.imgs63=[];
            $scope.imgs64=[];
            $scope.imgs65=[];
            $scope.ctrlScope.first1={};
            $scope.carLoadPics=[];
            $scope.ctrlScope.repay={};
            $scope.ctrlScope.item={};
            $scope.ctrlScope.message={};
            $scope.ctrlScope.message_2={};
            $scope.ctrlScope.car={};
            $scope.ctrlScope.training={};
            $scope.ctrlScope.CarMall={};
            $scope.ctrlScope.item.itemIsrecommend="0";
            $scope.ctrlScope.item.moveVip="0";
            $scope.ctrlScope.item.itemType="3";
            $scope.ctrlScope.item.itemIsnew="0";
            $scope.ctrlScope.item.itemCycle="30";
            $scope.ctrlScope.item.itemSingleMinInvestment="100";
            $scope.ctrlScope.item.itemMaxInvestment="0";
            $scope.ctrlScope.item.prepayment="0";
            $scope.ctrlScope.item.itemIsAuto="1";
            $scope.ctrlScope.item.debtTransferable="0";
            $scope.ctrlScope.item.itemLoanUse="短期周转";

        };

        //项目列表
        $scope.orderParams = {
            url: "/admin/item/getList"
        };

        //项目统计
        $scope.countItem=function(param){
            $http({
                method: 'POST',
                url:"/admin/item/getCount",
                data:param
            }).success(function (data){
                console.log(data);
                $scope.ctrlScope.count=data;
            }).error(function(data){

            });
        };
        $scope.countItem();


        //搜索
        $scope.search = function() {
            var paramdata={};
            $scope.ctrlScope.itemsearch.beginDate=$scope.ctrlScope.itemsearch.beginDateX;
            $scope.ctrlScope.itemsearch.endDate=$scope.ctrlScope.itemsearch.endDateX;
            $scope.ctrlScope.itemsearch.beginDate=$filter('date')($scope.ctrlScope.itemsearch.beginDate,'yyyy-MM-dd');
            $scope.ctrlScope.itemsearch.endDate=$filter('date')($scope.ctrlScope.itemsearch.endDate,'yyyy-MM-dd');
            $scope.orderParams.ajaxParam=$scope.ctrlScope.itemsearch;
            paramdata=$scope.ctrlScope.itemsearch;
            $scope.countItem(paramdata);
            $scope.orderParams.reload();
        };

        //搜索重置
        $scope.reset=function(){
            $scope.ctrlScope.itemsearch = {};
            $scope.search();
            $scope.countItem();
        };

        //上牌时间限制
        $scope.rangeTime=function(){
            $scope.year={};
            $scope.ctrlScope.item.carType=$scope.ctrlScope.item.carType1;
            var e = $scope.ctrlScope.item.carType;
            var inputYear=$filter('date')( $scope.ctrlScope.item.licensingTimeY, 'yyyy');

            if (e) {
                var f = JSON.parse(e);
                $scope.year.minyear = f.min_reg_year;
                $scope.year.maxyear = f.max_reg_year;

                    if (inputYear >= $scope.year.maxyear || inputYear <= $scope.year.minyear) {
                        return false

                    } else {
                        return true
                    }
            }
        };

        //创建
        $scope.addOrderModal=function(){
            $scope.checkSubmitFlg = false;
            $scope.modelInit();
            $scope.isEdit=false;
            $scope.ctrlScope.isReadonly=false;
            $scope.ctrlScope.Edit=true;
            $scope.ctrlScope.isCheck=false;

            $scope.ctrlScope.isCreate=true;
            $scope.ctrlScope.isNotCreate=false;



            $scope.itemAddModal = !$scope.itemAddModal;
            $scope.getUserList();
            $scope.getSysuserList();
            $scope.getCarBrands();
            $scope.countItem();

            $scope.compare=function(a,b){
                if(Number(a)==0){
                    return false
                }

                if (Number(a) >= Number(b)) {
                    return false
                } else {
                    return true
                }

            };


        };

        $scope.edit= function () {
            $scope.ctrlScope.isReadonly=false;
            $scope.ctrlScope.Edit=true;

        };

        $scope.check= function () {
            $scope.ctrlScope.isReadonly=true;
            $scope.ctrlScope.Edit=false;

        };
//修改内容
        $scope.openContentModal= function (id) {
            $scope.ctrlScope.item.itemContent='';
            $scope.id=id;
            $scope.contentModal=!$scope.contentModal;
                $http({
                    method: 'POST',
                    url: "/admin/item/getOneById",
                    data: {
                        id: id
                    }
                }).success(function(data) {
                    $scope.ctrlScope.item.itemContent= data.item.itemContent;
                }).error(function(data) {
                });

            $scope.submitContentForm= function () {
                $http({
                    method: 'POST',
                    url: "/admin/item/modifyContentById",
                    data: {
                        id: $scope.id,
                        itemContent: $scope.ctrlScope.item.itemContent
                    }
                }).success(function(data) {
                    if(data.result=='success'){
                        toastr.success("修改成功");
                        $scope.contentModal=!$scope.contentModal;
                    }else{
                        toastr.error("修改失败");
                    }
                }).error(function(data) {
                });
            }


        };
        //编辑
        $scope.openEditModal=function(id){
            $scope.checkSubmitFlg = false;
            $scope.isEdit=true;
            $scope.modelInit();
            $scope.ctrlScope.isReadonly=true;
            $scope.ctrlScope.Edit=false;
            $scope.ctrlScope.isCheck=true;

            $scope.ctrlScope.isCreate=false;
            $scope.ctrlScope.isNotCreate=true;
            $scope.edit();
            $scope.check();
            $scope.itemAddModal = !$scope.itemAddModal;
            $scope.getUserList();
            $scope.getSysuserList();


            $scope.getModalItem2(id);


            $scope.getCarBrands();

            $scope.ctrlScope.item.id=id;
        };

        //提前还款
        $scope.openrepayModal=function(id){
            $scope.ctrlScope.first={};
            $("#prepaymentCalculate").html("");
            $scope.repayModal = !$scope.repayModal;

            $scope.repayId=id;

            $scope.submitRepayForm = function() {

                $http({
                    method: 'POST',
                    url: "/admin/item/doRepayment",
                    data: {
                        itemId: $scope.repayId,
                        status:$scope.ctrlScope.first.status,
                        amount:$scope.ctrlScope.first.amount
                    }
                }).success(function(data) {
                    console.log(data);
                    if(data.result=="success"){
                        toastr.success("还款成功");
                        $scope.repayModal = !$scope.repayModal;
                        $scope.orderParams.reload();

                    }else{
                        if(data.messageText){
                            toastr.error(data.messageText);
                        }else{
                            toastr.error("提交失败");
                        }
                    }
                }).error(function(data) {
                });
            };



        };


        //提前还款输出金额后的相关提示信息
        $scope.amountChange=function(){
            $http({
                method: 'POST',
                url: "/admin/item/calculatePrepayment",
                data: {
                    itemId: $scope.repayId,
                    status:$scope.ctrlScope.first.status,
                    amount:$scope.ctrlScope.first.amount
                }
            }).success(function(data) {
                console.log(data);
                if(data.result==null){
                    $("#prepaymentCalculate").html("您本次提前还款利息："+data.inverest+"，支付违约金："+data.dedit+"，服务费为："+data.serverAmount+
                        "，总额为："+data.totalAmount+"，剩余应还本金：" +data.afterRepay+"，剩余应还利息："
                        +data.afterInverest+"，剩余应还服务费：" +data.afterServer+"，还款之后剩余应还总额："
                        +data.afterTotal)
                }else{
                   toastr.error(data.messageText)
                }
            }).error(function(data) {
            });
        };



        //添加
        $scope.openAddModal= function (id,type) {
            $scope.addItem={};
            $scope.ctrlScope.item={};
            $scope.ctrlScope.training={};
            $scope.ctrlScope.CarMall={};
            $scope.ctrlScope.message={};
            $scope.itemAddNewModal= !$scope.itemAddNewModal;
            $scope.addItem.type=type;
            $scope.addItem.id=id;


            $scope.getCarBrands();


            $scope.submitForm_add= function () {
                var datajson = {};
                var datajson2 = {};
                var datajson3 = {};
                var json = {};

                datajson = $scope.ctrlScope.car;
                datajson2 = $scope.ctrlScope.message;


                datajson.itemType=$scope.addItem.type;
                datajson.itemId=$scope.addItem.id;

                if($scope.addItem.type==3){
                    datajson3={};
                    var a = $scope.ctrlScope.item.carBrand1;
                    if (a) {
                        var b = JSON.parse(a);
                        $scope.ctrlScope.car.carBrand = b.name;
                    }

                    var c = $scope.ctrlScope.item.carDemio1;
                    if (c) {
                        var d = JSON.parse(c);
                        $scope.ctrlScope.car.carDemio = d.series_name;
                    }


                    var e = $scope.ctrlScope.item.carType1;
                    if (e) {
                        var f = JSON.parse(e);
                        $scope.ctrlScope.car.carType = f.model_name;
                    }

                }else if($scope.addItem.type==1){
                    datajson3=$scope.ctrlScope.training

                }else if($scope.addItem.type==2){
                    datajson3=$scope.ctrlScope.CarMall

                }

                $scope.ctrlScope.message.total = $scope.totalScore();
                $scope.ctrlScope.message.info = $scope.messageCount1();
                $scope.ctrlScope.message.assetsAndCredit = $scope.messageCount2();
                $scope.ctrlScope.message.jobNature = $scope.messageCount3();
                $scope.ctrlScope.message.collateralInfo = $scope.messageCount4();
                $scope.ctrlScope.message.guaranteeInfo = $scope.messageCount5();

                $scope.ctrlScope.car.licensingTime = $filter('date')($scope.ctrlScope.item.licensingTimeY, 'yyyy-MM-dd');


                json = angular.extend(datajson, datajson2,datajson3);
                console.info(json);
                $http({
                    method: 'POST',
                    url:"/admin/item/addItemInformation",
                    data:json
                }).success(function (data){
                    console.log(data);
                    if(data.result=="success"){

                        toastr.success("添加成功");
                        $scope.itemAddNewModal = !$scope.itemAddNewModal;
                        $scope.orderParams.reload();
                    }else{
                        if(data.messageText){
                            toastr.error(data.messageText);
                        }else{
                            toastr.error("添加失败");
                        }

                    }
                }).error(function(data){

                });
            };




        };

        //查看
        $scope.openViewModal=function(id,assetId){
            $scope.assetId=assetId;

            $scope.modelInit();
            $scope.viewItemModal = !$scope.viewItemModal;

            $scope.getModalItem(id);
            $scope.getModalInvest(id,assetId);
            $scope.downloadId=id;
        };

        //创建 / 编辑 提交
        $scope.submitForm = function(isValid) {
            if (!isValid) {
                toastr.error("信息填写有误");
                return;

            }
            if($scope.checkSubmitFlg ==true){
                return false; //当表单被提交过一次后checkSubmitFlg将变为true,根据判断将无法进行提交。
            }

            $scope.checkSubmitFlg =true;
            var datajson = {};
            var datajson2 = {};
            var datajson3 = {};


            var json = {};
            datajson = $scope.ctrlScope.item;
            datajson2 = $scope.ctrlScope.message;
            //if($scope.ctrlScope.item.itemType==3 || $scope.ctrlScope.item.itemType==1) {
            //    datajson2 = $scope.ctrlScope.message;
            //}else if($scope.ctrlScope.item.itemType==2){
            //    datajson2 = $scope.ctrlScope.message_2;
            //}
            datajson2.id=$scope.ctrlScope.item.id; //更换id为项目id
            datajson.itemCycleUnit=1;


            if ($scope.ctrlScope.repay.repaymentAudit1==1) {
                if( $scope.ctrlScope.item.repaymentAudit)
                datajson.repaymentAudit=$scope.ctrlScope.item.repaymentAudit

            }else{
                datajson.repaymentAudit = 0
            }

            if($scope.ctrlScope.item.itemType==3){
                datajson.itemRepayMethod=1
                if( $scope.ctrlScope.isReadonly) {
                    $scope.ctrlScope.car.licensingTime = $filter('date')( $scope.ctrlScope.car.licensingTime, 'yyyy-MM-dd');
                    datajson3=$scope.ctrlScope.car
                }else{

                    datajson3={};
                    datajson.isNewCar = $scope.ctrlScope.car.isNewCar;
                    var a = $scope.ctrlScope.item.carBrand1;
                    if (a) {
                        var b = JSON.parse(a);
                        datajson.carBrand = b.name;
                    }

                    var c = $scope.ctrlScope.item.carDemio1;
                    if (c) {
                        var d = JSON.parse(c);
                        datajson.carDemio = d.series_name;
                    }

                    var e = $scope.ctrlScope.item.carType1;
                    if (e) {
                        var f = JSON.parse(e);
                        datajson.carType = f.model_name;
                    }

                }
            }else if($scope.ctrlScope.item.itemType==1){
                datajson3=$scope.ctrlScope.training;
                datajson.itemRepayMethod=2

            }else if($scope.ctrlScope.item.itemType==2){
                datajson3=$scope.ctrlScope.CarMall;
                datajson.itemRepayMethod=3
            }

            datajson.total = $scope.totalScore();
            datajson.info = $scope.messageCount1();
            datajson.assetsAndCredit = $scope.messageCount2();
            datajson.jobNature = $scope.messageCount3();
            datajson.collateralInfo = $scope.messageCount4();
            datajson.guaranteeInfo = $scope.messageCount5();

            if($scope.ctrlScope.isCreate){
                var fistreleaseTime='';
                var fistdate=$filter('date')($scope.ctrlScope.first1.endTimeX,'yyyy-MM-dd');
                var firsthour=$scope.ctrlScope.first1.hour;
                var firstmin=$scope.ctrlScope.first1.min;
                fistreleaseTime=fistdate+' '+firsthour+':'+firstmin+':'+'00';
                datajson.endTime=fistreleaseTime;
            }else if($scope.isEdit){
                datajson.endTime=$filter('date')($scope.ctrlScope.item.endTimeX, 'yyyy-MM-dd HH:mm:ss')
            }


            datajson.licensingTime = $filter('date')($scope.ctrlScope.item.licensingTimeY, 'yyyy-MM-dd');


            datajson.pics='';
            if($scope.carLoadPics.length>0){
                for(var i=0;i<$scope.carLoadPics.length;i++){
                    datajson.pics =datajson.pics+ '|'+JSON.stringify($scope.carLoadPics[i]);
                }
            }



            json = angular.extend(datajson, datajson2,datajson3);
            console.info(json);

            var url='';
            if($scope.isEdit){
                url="/admin/item/modify";
            }else{
                url="/admin/item/add";
            }
            $http.post(url,json)
                .success(function(data) {

                    console.log(data)
                if(data.result=="success"){
                    $scope.modelInit();
                    toastr.success("提交成功");
                    $scope.itemAddModal = !$scope.itemAddModal;
                    $scope.orderParams.reload();
                    $scope.countItem();
                }else{

                    if(data.messageText){
                        toastr.error(data.messageText);
                    }else{
                        $scope.checkSubmitFlg =false;
                        toastr.error("提交失败");
                    }

                }
            }).error(function() {
            });
        };


        //查询项目信息
        $scope.getModalItem = function(id){
            $http({
                method: 'POST',
                url: "/admin/item/getOneById",
                data: {
                    id: id
                }
            }).success(function(data) {
                console.log(data);

                $scope.ctrlScope.item= data.item;
                $scope.ctrlScope.item.loanUser=data.loanUser;
                $scope.ctrlScope.item.guaranteeUser=data.guaranteeUser;


                if(data.item.itemSingleMinInvestment==0){
                    $scope.ctrlScope.item.itemSingleMinInvestment="不设起投";
                }else{
                    $scope.ctrlScope.item.itemSingleMinInvestment=data.item.itemSingleMinInvestment;
                }
                if(data.item.itemMaxInvestment==0){
                    $scope.ctrlScope.item.itemMaxInvestment="不设上限";
                }else{
                    $scope.ctrlScope.item.itemMaxInvestment=data.item.itemMaxInvestment;
                }

                if(data.item.releaseTime===null){
                    $scope.ctrlScope.item.releaseTime='非定时标';
                }else{
                    $scope.ctrlScope.item.releaseTime=$filter('date')(data.item.releaseTime, 'yyyy-MM-dd HH:mm:ss')
                }

                $scope.ctrlScope.time= data.time;

               if($scope.ctrlScope.item.prepayment==1) {
                   if (data.itemPrepayment.partialPrepayment == 1) {
                       $scope.ctrlScope.item.partialPrepayment = 1
                   } else {
                       $scope.ctrlScope.item.partialPrepayment = 0
                   }
                   if (data.itemPrepayment.allPrepayment == 1) {
                       $scope.ctrlScope.item.allPrepayment = 1
                   } else {
                       $scope.ctrlScope.item.allPrepayment = 0
                   }
               }else{

               }


                if(data.itemPrepayment){
                    if(data.itemPrepayment.repaymentAudit==0){
                        $scope.ctrlScope.repay.repaymentAudit1=0;

                    }else{
                        $scope.ctrlScope.repay.repaymentAudit1=1;
                        $scope.ctrlScope.item.repaymentAudit=data.itemPrepayment.repaymentAudit;
                    }
                }
                    $scope.personalImgs=[];
                    $scope.carImgs=[];
                    $scope.procedureImgs=[];
                    $scope.riskImgs=[];
                    $scope.skillImgs=[];
                    for(var i=0;i<data.pictureList.length;i++){
                        if(data.pictureList[i].itemPictureType==1){
                            $scope.personalImgs.push(data.pictureList[i]);
                        }else if(data.pictureList[i].itemPictureType==2){
                            $scope.carImgs.push(data.pictureList[i]);
                        }else if(data.pictureList[i].itemPictureType==3){
                            $scope.procedureImgs.push(data.pictureList[i]);
                        }else if(data.pictureList[i].itemPictureType==4){
                            $scope.riskImgs.push(data.pictureList[i]);
                        }else if(data.pictureList[i].itemPictureType==5){
                            $scope.skillImgs.push(data.pictureList[i]);
                        }
                    }
            }).error(function(data) {
            });
        };

        //查询项目信息
        $scope.getModalItem2 = function(id){

            $http({
                method: 'POST',
                url: "/admin/item/getOneById",
                data: {
                    id: id
                }
            }).success(function(data) {
                console.log(data);

                $scope.ctrlScope.item= data.item;
                $scope.ctrlScope.item.loanUser=data.loanUser;
                $scope.ctrlScope.item.guaranteeUser=data.guaranteeUser;

                if($scope.ctrlScope.item.prepayment==1) {
                    if (data.itemPrepayment.partialPrepayment == 1) {
                        $scope.ctrlScope.item.partialPrepayment = 1
                    } else {
                        $scope.ctrlScope.item.partialPrepayment = 0
                    }
                    if (data.itemPrepayment.allPrepayment == 1) {
                        $scope.ctrlScope.item.allPrepayment = 1
                    } else {
                        $scope.ctrlScope.item.allPrepayment = 0
                    }
                }else{

                }

                if(data.itemPrepayment){
                    if(data.itemPrepayment.repaymentAudit==0){
                        $scope.ctrlScope.repay.repaymentAudit1=0;

                    }else{
                        $scope.ctrlScope.repay.repaymentAudit1=1;
                        $scope.ctrlScope.item.repaymentAudit=data.itemPrepayment.repaymentAudit;
                    }
                }
                $scope.ctrlScope.item.endTimeX=data.item.endTime;
                //$scope.imgs=[];
                //$scope.pics='';
                //$scope.picture=function(){
                //    for(var i=0;i<data.pictureList.length;i++){
                //        if(data.pictureList[i].picturePath!=''){
                //            $scope.imgs.push(data.pictureList[i].picturePath);
                //            $scope.pics=$scope.pics+'|'+data.pictureList[i].picturePath
                //        }
                //
                //    }
                //
                //};
                //$scope.picture();

                for(var i=0;i<data.pictureList.length;i++){
                    if(data.pictureList[i].itemPictureType==1){
                        $scope.imgs1.push(data.pictureList[i].picturePath);
                        $scope.pics1.type=1;
                        $scope.pics1.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics1)
                    }
                    if(data.pictureList[i].itemPictureType==2){
                        $scope.imgs2.push(data.pictureList[i].picturePath);
                        $scope.pics2.type=2;
                        $scope.pics2.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics2)
                    }
                    if(data.pictureList[i].itemPictureType==3){
                        $scope.imgs3.push(data.pictureList[i].picturePath);
                        $scope.pics3.type=3;
                        $scope.pics3.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics3)
                    }
                    if(data.pictureList[i].itemPictureType==4){
                        $scope.imgs4.push(data.pictureList[i].picturePath);
                        $scope.pics4.type=4;
                        $scope.pics4.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics4)
                    }
                    if(data.pictureList[i].itemPictureType==5){
                        $scope.imgs5.push(data.pictureList[i].picturePath);
                        $scope.pics5.type=5;
                        $scope.pics5.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics5)
                    }
                    if(data.pictureList[i].itemPictureType==6){
                        $scope.imgs6.push(data.pictureList[i].picturePath);
                        $scope.pics6.type=6;
                        $scope.pics6.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics6)
                    }
                    if(data.pictureList[i].itemPictureType==7){
                        $scope.imgs7.push(data.pictureList[i].picturePath);
                        $scope.pics7.type=7;
                        $scope.pics7.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics7)
                    }
                    if(data.pictureList[i].itemPictureType==8){
                        $scope.imgs8.push(data.pictureList[i].picturePath);
                        $scope.pics8.type=8;
                        $scope.pics8.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics8)
                    }

                    if(data.pictureList[i].itemPictureType==21){
                        $scope.imgs21.push(data.pictureList[i].picturePath);
                        $scope.pics21.type=21;
                        $scope.pics21.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics21)
                    }
                    if(data.pictureList[i].itemPictureType==22){
                        $scope.imgs22.push(data.pictureList[i].picturePath);
                        $scope.pics22.type=22;
                        $scope.pics22.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics22)
                    }
                    if(data.pictureList[i].itemPictureType==23){
                        $scope.imgs23.push(data.pictureList[i].picturePath);
                        $scope.pics23.type=23;
                        $scope.pics23.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics23)
                    }
                    if(data.pictureList[i].itemPictureType==24){
                        $scope.imgs24.push(data.pictureList[i].picturePath);
                        $scope.pics24.type=24;
                        $scope.pics24.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics24)
                    }
                    if(data.pictureList[i].itemPictureType==25){
                        $scope.imgs25.push(data.pictureList[i].picturePath);
                        $scope.pics25.type=25;
                        $scope.pics25.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics25)
                    }
                    if(data.pictureList[i].itemPictureType==26){
                        $scope.imgs26.push(data.pictureList[i].picturePath);
                        $scope.pics26.type=26;
                        $scope.pics26.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics26)
                    }
                    if(data.pictureList[i].itemPictureType==27){
                        $scope.imgs27.push(data.pictureList[i].picturePath);
                        $scope.pics27.type=27;
                        $scope.pics27.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics27)
                    }
                    if(data.pictureList[i].itemPictureType==28){
                        $scope.imgs28.push(data.pictureList[i].picturePath);
                        $scope.pics28.type=28;
                        $scope.pics28.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics28)
                    }
                    if(data.pictureList[i].itemPictureType==29){
                        $scope.imgs29.push(data.pictureList[i].picturePath);
                        $scope.pics29.type=29;
                        $scope.pics29.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics29)
                    }
                    if(data.pictureList[i].itemPictureType==30){
                        $scope.imgs30.push(data.pictureList[i].picturePath);
                        $scope.pics30.type=30;
                        $scope.pics30.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics30)
                    }

                    if(data.pictureList[i].itemPictureType==41){
                        $scope.imgs41.push(data.pictureList[i].picturePath);
                        $scope.pics41.type=41;
                        $scope.pics41.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics41)
                    }
                    if(data.pictureList[i].itemPictureType==42){
                        $scope.imgs42.push(data.pictureList[i].picturePath);
                        $scope.pics42.type=42;
                        $scope.pics42.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics42)
                    }
                    if(data.pictureList[i].itemPictureType==43){
                        $scope.imgs43.push(data.pictureList[i].picturePath);
                        $scope.pics43.type=43;
                        $scope.pics43.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics43)
                    }
                    if(data.pictureList[i].itemPictureType==44){
                        $scope.imgs44.push(data.pictureList[i].picturePath);
                        $scope.pics44.type=44;
                        $scope.pics44.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics44)
                    }
                    if(data.pictureList[i].itemPictureType==45){
                        $scope.imgs45.push(data.pictureList[i].picturePath);
                        $scope.pics45.type=45;
                        $scope.pics45.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics45)
                    }
                    if(data.pictureList[i].itemPictureType==46){
                        $scope.imgs46.push(data.pictureList[i].picturePath);
                        $scope.pics46.type=46;
                        $scope.pics46.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics46)
                    }
                    if(data.pictureList[i].itemPictureType==47){
                        $scope.imgs47.push(data.pictureList[i].picturePath);
                        $scope.pics47.type=47;
                        $scope.pics47.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics47)
                    }
                    if(data.pictureList[i].itemPictureType==48){
                        $scope.imgs48.push(data.pictureList[i].picturePath);
                        $scope.pics48.type=48;
                        $scope.pics48.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics48)
                    }
                    if(data.pictureList[i].itemPictureType==61){
                        $scope.imgs61.push(data.pictureList[i].picturePath);
                        $scope.pics61.type=61;
                        $scope.pics61.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics61)
                    }
                    if(data.pictureList[i].itemPictureType==62){
                        $scope.imgs62.push(data.pictureList[i].picturePath);
                        $scope.pics62.type=62;
                        $scope.pics62.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics62)
                    }
                    if(data.pictureList[i].itemPictureType==63){
                        $scope.imgs63.push(data.pictureList[i].picturePath);
                        $scope.pics63.type=63;
                        $scope.pics63.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics63)
                    }
                    if(data.pictureList[i].itemPictureType==64){
                        $scope.imgs64.push(data.pictureList[i].picturePath);
                        $scope.pics64.type=64;
                        $scope.pics64.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics64)
                    }
                    if(data.pictureList[i].itemPictureType==65){
                        $scope.imgs65.push(data.pictureList[i].picturePath);
                        $scope.pics65.type=65;
                        $scope.pics65.url=data.pictureList[i].picturePath;
                        $scope.carLoadPics.push($scope.pics65)
                    }


                }

            }).error(function(data) {
            });
        };






        //查询投资信息
        $scope.orderParams1 = {
            url: "/admin/item/getItemInvestByItemId"
        };
        $scope.assetOrderParams1 = {
            url: "/admin/asset/getInvestListByItemId"
        };
        $scope.getModalInvest = function(id,assetId) {
            if(assetId != null){
                $scope.assetOrderParams1.ajaxParam = {itemId:id};
                $scope.assetOrderParams1.reload();
            }else{
                $scope.orderParams1.ajaxParam = {id:id};
                $scope.orderParams1.reload();
            }

        };


        //获取借款人列表
        $scope.getUserList=function(){
            $scope.username={};
            $http({
                method: 'POST',
                url: "/admin/user/getNoPageList",
                data:{type:2}
            }).success(function(data) {
                console.log(data)
                $scope.username=data;
            }).error(function() {
            });
        };

        //获取担保人列表
        $scope.getSysuserList=function(){
            $scope.sysUername={};
            $http({
                method: 'POST',
                url: "/admin/sysuser/noPageList",
                data:{type:2}
            }).success(function(data) {
                console.log(data)
                $scope.sysUername=data;
            }).error(function() {
            });
        };

        //获取车辆品牌
        $scope.getCarBrands=function(){
            $scope.carBrands={};
            var CarList=[];
            $http({
                method: 'POST',
                url: "/admin/getCarBrandList"
            }).success(function(data) {

                for(var i=0;i<data.length;i++){
                    for(var j=0;j<data[i].list.length;j++){
                        CarList.push({name:data[i].list[j].brand_name,id:data[i].list[j].brand_id});
                    }
                }
                $scope.carBrands=CarList;
            }).error(function() {
            });
        };

        //获取车系
        $scope.getCarSeries=function(){
            $scope.carSeries={};
            $scope.ctrlScope.item.carBrand=$scope.ctrlScope.item.carBrand1
            var id=(JSON.parse($scope.ctrlScope.item.carBrand)).id;
            $http({
                method: 'POST',
                url: "/admin/getCarSeriesList",
                data:{brandId:id}
            }).success(function(data) {
                $scope.carSeries=data;
            }).error(function() {
            });
        };

        //获取车型
        $scope.getCarTypes=function(){
            $scope.carTypes={};
            $scope.ctrlScope.item.carDemio=$scope.ctrlScope.item.carDemio1;
            var id=(JSON.parse($scope.ctrlScope.item.carDemio)).series_id;
            $http({
                method: 'POST',
                url: "/admin/getCarModelList",
                data:{seriesId:id}
            }).success(function(data) {
                $scope.carTypes=data;
                console.log(data)
            }).error(function() {
            });
        };
        //评估价格
        $scope.price2=function(){
            $scope.ctrlScope.item.licensingTime=$scope.ctrlScope.item.licensingTimeY;
            $scope.ctrlScope.item.licensingTime = $filter('date')( $scope.ctrlScope.item.licensingTime, 'yyyy-MM');
            $scope.ctrlScope.item.carType=$scope.ctrlScope.item.carType1;
            if($scope.ctrlScope.item.carType){
                var datajson={
                    modelId:(JSON.parse($scope.ctrlScope.item.carType)).model_id,
                    regDate:$scope.ctrlScope.item.licensingTime,
                    mile:$scope.ctrlScope.car.kilometers
                };
            }else{
                return
            }
            console.log(datajson)
            $http({
                method: 'POST',
                url: "/admin/queryPrice",
                data:datajson
            }).success(function(data) {
                console.log(data)
                if(data.result=='success'){
                    $scope.ctrlScope.car.assessPrice=data.price+'元'
                }else{
                    toastr.error('参数错误');
                }
            }).error(function() {
            });
        };
        //评估价格
        $scope.price=function(){
            $scope.ctrlScope.item.licensingTime=$scope.ctrlScope.item.licensingTimeY;
            $scope.ctrlScope.item.licensingTime = $filter('date')( $scope.ctrlScope.item.licensingTime, 'yyyy-MM');
            $scope.ctrlScope.item.carType=$scope.ctrlScope.item.carType1;
            if($scope.ctrlScope.item.carType){
                var datajson={
                    modelId:(JSON.parse($scope.ctrlScope.item.carType)).model_id,
                    regDate:$scope.ctrlScope.item.licensingTime,
                    mile:$scope.ctrlScope.item.kilometers
                };
            }else{
                return
            }
            console.log(datajson)
            $http({
                method: 'POST',
                url: "/admin/queryPrice",
                data:datajson
            }).success(function(data) {
                console.log(data)
                if(data.result=='success'){
                    $scope.ctrlScope.item.assessPrice=data.price+'元'
                }else{
                    toastr.error('参数错误');
                }
            }).error(function() {
            });
        };


        //上传图片
        $scope.selectUpload=function(){
            $scope.uploadTab.active=true;
        };

       $scope.onFileSelect = function (file) {
            console.log(file);
        };

        //车贷宝--3，学车宝--1，车商宝--2
        $scope.carLoadPics=[];

        //1、借款人信息
//1.1身份证
        $scope.imgs1=[];
        $scope.pics1={};
        $scope.removeImg1=function(index) {
            $scope.imgs1.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics1) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic1 =function(file) {
                file.upload = Upload.upload({
                    url: '/itemFile',
                    headers: {
                        'optional-header': 'header-value'
                    },
                    data: {file: file}
                });
            file.upload.then(function (response) {

                $scope.pics1.url= response.data.url;
                $scope.pics1.type= 1;
                $scope.imgs1.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics1);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };

//1.2户口本
        $scope.imgs2=[];
        $scope.pics2={};
        $scope.removeImg2=function(index) {
            $scope.imgs2.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics2) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic2 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics2.url= response.data.url;
                $scope.pics2.type= 2;
                $scope.imgs2.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics2);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };

//1.3结婚证
        $scope.imgs3=[];
        $scope.pics3={};
        $scope.removeImg3=function(index) {
            $scope.imgs3.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics3) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic3 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics3.url= response.data.url;
                $scope.pics3.type= 3;
                $scope.imgs3.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics3);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };

//1.4房产证
        $scope.imgs4=[];
        $scope.pics4={};
        $scope.removeImg4=function(index) {
            $scope.imgs4.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics4) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic4 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics4.url= response.data.url;
                $scope.pics4.type= 4;
                $scope.imgs4.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics4);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
//1.5收入证明
        $scope.imgs5=[];
        $scope.pics5={};
        $scope.removeImg5=function(index) {
            $scope.imgs5.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics5) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic5 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics5.url= response.data.url;
                $scope.pics5.type= 5;
                $scope.imgs5.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics5);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
//1.6
        $scope.imgs6=[];
        $scope.pics6={};
        $scope.removeImg6=function(index) {
            $scope.imgs6.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics6) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic6 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics6.url= response.data.url;
                $scope.pics6.type= 6;
                $scope.imgs6.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics6);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
//1.7
    $scope.imgs7=[];
    $scope.pics7={};
    $scope.removeImg7=function(index) {
        $scope.imgs7.splice(index,1);
        for(var i=0; i<$scope.carLoadPics.length; i++) {
            if($scope.carLoadPics[i] == $scope.pics7) {
                $scope.carLoadPics.splice(i, 1);
            }
        }
        console.log($scope.carLoadPics)
    };

    $scope.uploadPic7 =function(file) {
        file.upload = Upload.upload({
            url: '/itemFile',
            headers: {
                'optional-header': 'header-value'
            },
            data: {file: file}
        });
        file.upload.then(function (response) {

            $scope.pics7.url= response.data.url;
            $scope.pics7.type= 7;
            $scope.imgs7.push(response.data.url);
            $scope.defaultPicFile="css/img/updatepic.png";
            $scope.carLoadPics.push($scope.pics7);
            console.log($scope.carLoadPics)
        }, function (response) {
            if (response.status > 0)
                $scope.errorMsg = response.status + ': ' + response.data;
        }, function (evt) {
            file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
        });
        file.upload.xhr(function (xhr) {
        });
    };
//1.8
        $scope.imgs8=[];
        $scope.pics8={};
        $scope.removeImg8=function(index) {
            $scope.imgs8.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics8) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic8 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics8.url= response.data.url;
                $scope.pics8.type= 8;
                $scope.imgs8.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics8);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
//2.1外观前
        $scope.imgs21=[];
        $scope.pics21={};
        $scope.removeImg21=function(index) {
            $scope.imgs21.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics21) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic21 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics21.url= response.data.url;
                $scope.pics21.type= 21;
                $scope.imgs21.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics21);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
//2.2外观后
        $scope.imgs22=[];
        $scope.pics22={};
        $scope.removeImg22=function(index) {
            $scope.imgs22.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics22) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic22 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics22.url= response.data.url;
                $scope.pics22.type= 22;
                $scope.imgs22.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics22);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //2.3里程表
        $scope.imgs23=[];
        $scope.pics23={};
        $scope.removeImg23=function(index) {
            $scope.imgs23.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics23) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic23 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics23.url= response.data.url;
                $scope.pics23.type= 23;
                $scope.imgs23.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics23);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //2.4中控台
        $scope.imgs24=[];
        $scope.pics24={};
        $scope.removeImg24=function(index) {
            $scope.imgs24.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics24) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic24 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics24.url= response.data.url;
                $scope.pics24.type= 24;
                $scope.imgs24.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics24);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //2.5铭牌
        $scope.imgs25=[];
        $scope.pics25={};
        $scope.removeImg25=function(index) {
            $scope.imgs25.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics25) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic25 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics25.url= response.data.url;
                $scope.pics25.type= 25;
                $scope.imgs25.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics25);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //2.6人车合照
        $scope.imgs26=[];
        $scope.pics26={};
        $scope.removeImg26=function(index) {
            $scope.imgs26.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics26) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic26 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics26.url= response.data.url;
                $scope.pics26.type= 26;
                $scope.imgs26.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics26);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //2.7
        $scope.imgs27=[];
        $scope.pics27={};
        $scope.removeImg27=function(index) {
            $scope.imgs27.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics27) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic27 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics27.url= response.data.url;
                $scope.pics27.type= 27;
                $scope.imgs27.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics27);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //2.8
        $scope.imgs28=[];
        $scope.pics28={};
        $scope.removeImg28=function(index) {
            $scope.imgs28.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics28) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic28 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics28.url= response.data.url;
                $scope.pics28.type= 28;
                $scope.imgs28.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics28);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //2.9
        $scope.imgs29=[];
        $scope.pics29={};
        $scope.removeImg29=function(index) {
            $scope.imgs29.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics29) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic29 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics29.url= response.data.url;
                $scope.pics29.type= 29;
                $scope.imgs29.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics29);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //2.10
        $scope.imgs30=[];
        $scope.pics30={};
        $scope.removeImg30=function(index) {
            $scope.imgs30.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics30) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic30=function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics30.url= response.data.url;
                $scope.pics30.type= 30;
                $scope.imgs30.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics30);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //4.1购车合同
        $scope.imgs41=[];
        $scope.pics41={};
        $scope.removeImg41=function(index) {
            $scope.imgs41.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics41) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic41 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics41.url= response.data.url;
                $scope.pics41.type= 41;
                $scope.imgs41.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics41);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //4.2担保函
        $scope.imgs42=[];
        $scope.pics42={};
        $scope.removeImg42=function(index) {
            $scope.imgs42.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics42) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic42 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics42.url= response.data.url;
                $scope.pics42.type= 42;
                $scope.imgs42.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics42);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //4.3委托书
        $scope.imgs43=[];
        $scope.pics43={};
        $scope.removeImg43=function(index) {
            $scope.imgs43.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics43) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic43 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics43.url= response.data.url;
                $scope.pics43.type= 43;
                $scope.imgs43.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics43);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //4.4行驶证
        $scope.imgs44=[];
        $scope.pics44={};
        $scope.removeImg44=function(index) {
            $scope.imgs44.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics44) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic44 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics44.url= response.data.url;
                $scope.pics44.type= 44;
                $scope.imgs44.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics44);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //4.5发票
        $scope.imgs45=[];
        $scope.pics45={};
        $scope.removeImg45=function(index) {
            $scope.imgs45.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics45) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic45 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics45.url= response.data.url;
                $scope.pics45.type= 45;
                $scope.imgs45.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics45);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //4.6登记证书
        $scope.imgs46=[];
        $scope.pics46={};
        $scope.removeImg46=function(index) {
            $scope.imgs46.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics46) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic46 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics46.url= response.data.url;
                $scope.pics46.type= 46;
                $scope.imgs46.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics46);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //4.7
        $scope.imgs47=[];
        $scope.pics47={};
        $scope.removeImg47=function(index) {
            $scope.imgs47.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics47) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic47 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics47.url= response.data.url;
                $scope.pics47.type= 47;
                $scope.imgs47.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics47);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //4.8
        $scope.imgs48=[];
        $scope.pics48={};
        $scope.removeImg48=function(index) {
            $scope.imgs48.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics48) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic48 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics48.url= response.data.url;
                $scope.pics48.type= 48;
                $scope.imgs48.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics48);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };

        //6.1
        $scope.imgs61=[];
        $scope.pics61={};
        $scope.removeImg61=function(index) {
            $scope.imgs61.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics61) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic61 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics61.url= response.data.url;
                $scope.pics61.type= 61;
                $scope.imgs61.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics61);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //6.2
        $scope.imgs62=[];
        $scope.pics62={};
        $scope.removeImg62=function(index) {
            $scope.imgs62.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics62) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic62 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics62.url= response.data.url;
                $scope.pics62.type= 62;
                $scope.imgs62.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics62);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //6.3
        $scope.imgs63=[];
        $scope.pics63={};
        $scope.removeImg63=function(index) {
            $scope.imgs63.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics63) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic63 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics63.url= response.data.url;
                $scope.pics63.type= 63;
                $scope.imgs63.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics63);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //6.4
        $scope.imgs64=[];
        $scope.pics64={};
        $scope.removeImg64=function(index) {
            $scope.imgs64.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics64) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic64 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics64.url= response.data.url;
                $scope.pics64.type= 64;
                $scope.imgs64.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics64);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };
        //6.5
        $scope.imgs65=[];
        $scope.pics65={};
        $scope.removeImg65=function(index) {
            $scope.imgs65.splice(index,1);
            for(var i=0; i<$scope.carLoadPics.length; i++) {
                if($scope.carLoadPics[i] == $scope.pics65) {
                    $scope.carLoadPics.splice(i, 1);
                }
            }
            console.log($scope.carLoadPics)
        };

        $scope.uploadPic65 =function(file) {
            file.upload = Upload.upload({
                url: '/itemFile',
                headers: {
                    'optional-header': 'header-value'
                },
                data: {file: file}
            });
            file.upload.then(function (response) {

                $scope.pics65.url= response.data.url;
                $scope.pics65.type= 65;
                $scope.imgs65.push(response.data.url);
                $scope.defaultPicFile="css/img/updatepic.png";
                $scope.carLoadPics.push($scope.pics65);
                console.log($scope.carLoadPics)
            }, function (response) {
                if (response.status > 0)
                    $scope.errorMsg = response.status + ': ' + response.data;
            }, function (evt) {
                file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
            });
            file.upload.xhr(function (xhr) {
            });
        };

        //车贷宝
        //计算个人信息总分
        $scope.messageCount1= function () {
            var total=0;
            var param=[
                Number($scope.ctrlScope.message.age),
                Number($scope.ctrlScope.message.sex),
                Number($scope.ctrlScope.message.education),
                Number($scope.ctrlScope.message.marital),
                Number($scope.ctrlScope.message.city)
            ];
           for(var i= 0;i<param.length;i++) {
               if (!param[i]) {
                   param[i] = 0;
               }
           }

            if(param[0]==1){
                param[0]=1
            }else if(param[0]==2){
                param[0]=2
            }else if(param[0]==3){
                param[0]=3
            }else if(param[0]==4){
                param[0]=2
            }else if(param[0]==5){
                param[0]=1
            }else{
                param[0]=0
            }


            if(param[1]==1){
                param[1]=1
            }else if(param[1]==2){
                param[1]=2
            }else{
                param[1]=0
            }



            if(param[2]==1){
                param[2]=3
            }else if(param[2]==2){
                param[2]=2
            }else if(param[2]==3){
                param[2]=1
            } else {
                param[2]=0
            }


            if (param[3] == 1) {
                param[3] = 1
            } else if (param[3] == 2) {
                param[3] =2
            }else{
                param[3] =0
            }


            if (param[4] == 1) {
                param[4] = 3
            } else if (param[4] == 2) {
                param[4] =2
            }else if (param[4] == 3) {
                param[4] =1
            }
            else{
                param[4] =0
            }


            total= param[0]+param[1]+param[2]+param[3]+param[4];

            return total;
        };

        //计算个人资产及征信总分
        $scope.messageCount2= function () {
            var total=0;
            var param=[
                Number($scope.ctrlScope.message.monthlyIncome),
                Number($scope.ctrlScope.message.house),
                Number($scope.ctrlScope.message.creditease),
                Number($scope.ctrlScope.message.creditUse),
                Number($scope.ctrlScope.message.lateTimes)
            ];
            for(var i= 0;i<param.length;i++) {
                if (!param[i]) {
                    param[i] = 0;
                }
            }
            if(param[0]==1){
                param[0]=5
            }else if(param[0]==2){
                param[0]=4
            }else if(param[0]==3){
                param[0]=3
            }else if(param[0]==4){
                param[0]=2
            }else if(param[0]==5){
                param[0]=1
            }else{
                param[0]=0
            }


            if(param[1]==1){
                param[1]=4
            }else if(param[1]==2){
                param[1]=3
            }else if(param[1]==3){
                param[1]=1
            }else{
                param[1]=0
            }



            if(param[2]==1){
                param[2]=3
            }else if(param[2]==2){
                param[2]=2
            } else {
                param[2]=0
            }


            if (param[3] == 1) {
                param[3] = 3
            } else if (param[3] == 2) {
                param[3] = 2
            }else{
                param[3] = 0
            }


            if (param[4] == 1) {
                param[4] = 4
            } else if (param[4] == 2) {
                param[4] =3
            } else if(param[4] == 3){
                param[4] = 2
            }else if(param[4] == 4){
                param[4] =1
            }else{
                param[4] = 0
            }
            total= param[0]+param[1]+param[2]+param[3]+param[4];

            return total;
        };

        //计算工作性质总分
        $scope.messageCount3= function () {
            var total=0;
            var param=[
                Number($scope.ctrlScope.message.nowWorkLife),
                Number($scope.ctrlScope.message.company),
                Number($scope.ctrlScope.message.workLife),
                Number($scope.ctrlScope.message.post)
            ];
            for(var i= 0;i<param.length;i++) {
                if (!param[i]) {
                    param[i] = 0;
                }
            }
                    if(param[0]==1){
                        param[0]=3
                    }else if(param[0]==2){
                        param[0]=2
                    }else if(param[0]==3){
                        param[0]=1
                    }else{
                        param[0]=0
                    }


                     if(param[1]==1){
                         param[1]=3
                     }else if(param[1]==2){
                         param[1]=2
                     }else if(param[1]==3){
                         param[1]=1
                     }else{
                         param[1]=0
                     }



                   if(param[2]==1){
                       param[2]=3
                   }else if(param[2]==2){
                       param[2]=2
                   }else if(param[2]==3||param[2]==4){
                       param[2]=1
                   } else {
                       param[2]=0
                   }


                   if (param[3] == 1) {
                       param[3] = 3
                   } else if (param[3] == 2) {
                       param[3] = 2
                   } else if(param[3] == 3){
                       param[3] = 1
                   }else{
                       param[3] = 0
                   }

                total= param[0]+param[1]+param[2]+param[3];

            return total;
        };

        //抵（质）押物信息
        $scope.messageCount4= function () {
            var total=0;
            var param=[
                Number($scope.ctrlScope.message.discount),
                Number($scope.ctrlScope.message.circulation),
                Number($scope.ctrlScope.message.hedge),
                Number($scope.ctrlScope.message.supervise),
                Number($scope.ctrlScope.message.risk)
            ];

            for(var i= 0;i<param.length;i++) {
                if (!param[i]) {
                    param[i] = 0;

                }
            }

            if(param[0]==1){
                param[0]=8
            }else if(param[0]==2){
                param[0]=7
            }else if(param[0]==3){
                param[0]=6
            }else if(param[0]==4){
                param[0]=3
            }else{
                param[0]=0
            }


            if(param[1]==1){
                param[1]=5
            }else if(param[1]==2){
                param[1]=3
            }else if(param[1]==3){
                param[1]=1
            }else{
                param[1]=0
            }



            if(param[2]==1){
                param[2]=3
            }else if(param[2]==2){
                param[2]=2
            }else if(param[2]==3){
                param[2]=1
            } else {
                param[2]=0
            }


            if (param[3] == 1) {
                param[3] = 8
            } else if (param[3] == 2) {
                param[3] = 6
            } else if(param[3] == 3){
                param[3] = 5
            }else{
                param[3] = 0
            }


            if (param[4] == 1) {
                param[4] = 8
            } else if (param[4] == 2) {
                param[4] =6
            } else if(param[4] == 3){
                param[4] = 4
            }else{
                param[4] = 0
            }

            total= param[0]+param[1]+param[2]+param[3]+param[4];
            return total;
        };

        //担保信息
        $scope.messageCount5= function () {
            var total=0;
            var param=[
                Number($scope.ctrlScope.message.guarantee)
            ];


            if (!param[0]) {
                    param[0] = 0;

                }

             if(param[0]==1){
                    param[0]=24
                }else if(param[0]==2){
                    param[0]=20
                }else if(param[0]==3){
                    param[0]=15
                }else if(param[0]==4){
                    param[0]=10
                }else if(param[0]==5){
                    param[0]=5
                }
                else{
                    param[0]=0
                }
            total=param[0];
            return total;
            };

        //总得分
        $scope.totalScore= function () {
            var totalScore=0;

            $scope.score={
                a:false,
                b:false,
                c:false,
                d:false,
                e:false
            };

            totalScore=$scope.messageCount1()+$scope.messageCount2()+$scope.messageCount3()+$scope.messageCount4()+$scope.messageCount5();
            if(totalScore > 90){
                $scope.score.a=true
            }else if(totalScore<=90 && totalScore>85){
                $scope.score.b=true
            }else if(totalScore<=85 && totalScore>75){
                $scope.score.c=true
            }else if(totalScore<=75 && totalScore>65){
                $scope.score.d=true
            }
            return totalScore
        }



        //车商宝
        //计算个人信息总分
        $scope.messageCount1_2= function () {
            var total=0;
            var param=[
                Number($scope.ctrlScope.message_2.age),
                Number($scope.ctrlScope.message_2.sex),
                Number($scope.ctrlScope.message_2.education),
                Number($scope.ctrlScope.message_2.marital),
                Number($scope.ctrlScope.message_2.city)
            ];
            for(var i= 0;i<param.length;i++) {
                if (!param[i]) {
                    param[i] = 0;
                }
            }

            if(param[0]==1){
                param[0]=1
            }else if(param[0]==2){
                param[0]=2
            }else if(param[0]==3){
                param[0]=3
            }else if(param[0]==4){
                param[0]=2
            }else if(param[0]==5){
                param[0]=1
            }else{
                param[0]=0
            }


            if(param[1]==1){
                param[1]=1
            }else if(param[1]==2){
                param[1]=2
            }else{
                param[1]=0
            }



            if(param[2]==1){
                param[2]=3
            }else if(param[2]==2){
                param[2]=2
            }else if(param[2]==3){
                param[2]=1
            } else {
                param[2]=0
            }


            if (param[3] == 1) {
                param[3] = 1
            } else if (param[3] == 2) {
                param[3] =2
            }else{
                param[3] =0
            }


            if (param[4] == 1) {
                param[4] = 3
            } else if (param[4] == 2) {
                param[4] =2
            }else if (param[4] == 3) {
                param[4] =1
            }
            else{
                param[4] =0
            }


            total= param[0]+param[1]+param[2]+param[3]+param[4];

            return total;
        };

        //法人及股东个人资产及征信
        $scope.messageCount2_2= function () {
            var total=0;
            var param=[
                Number($scope.ctrlScope.message_2.house),
                Number($scope.ctrlScope.message_2.creditease),
                Number($scope.ctrlScope.message_2.creditUse),
                Number($scope.ctrlScope.message_2.lateTimes)
            ];
            for(var i= 0;i<param.length;i++) {
                if (!param[i]) {
                    param[i] = 0;
                }
            }
            if(param[0]==1){
                param[0]=10
            }else if(param[0]==2){
                param[0]=5
            }else if(param[0]==3){
                param[0]=0

            }else{
                param[0]=0
            }


            if(param[1]==1){
                param[1]=3
            }else if(param[1]==2){
                param[1]=2
            }else if(param[1]==3){
                param[1]=0
            }else{
                param[1]=0
            }



            if(param[2]==1){
                param[2]=3
            }else if(param[2]==2){
                param[2]=2
            } else if(param[2]==3){
                param[2]=0
            }else if(param[2]==4){
                param[2]=2
            }else {
                param[2]=0
            }


            if (param[3] == 1) {
                param[3] = 4
            } else if (param[3] == 2) {
                param[3] = 3
            } else if (param[3] == 3) {
                param[3] = 2
            } else if (param[3] == 4) {
                param[3] = 1
            } else if (param[3] == 5) {
                param[3] = 0
            }else{
                param[3] = 0
            }

            total= param[0]+param[1]+param[2]+param[3];

            return total;
        };

        //企业经营情况
        $scope.messageCount3_2= function () {
            var total=0;
            var param=[
                Number($scope.ctrlScope.message_2.nowWorkLife),
                Number($scope.ctrlScope.message_2.company),
                Number($scope.ctrlScope.message_2.workLife),
                Number($scope.ctrlScope.message_2.post),
                Number($scope.ctrlScope.message_2.discount),
                Number($scope.ctrlScope.message_2.circulation),
                Number($scope.ctrlScope.message_2.hedge)
            ];
            for(var i= 0;i<param.length;i++) {
                if (!param[i]) {
                    param[i] = 0;
                }
            }
            if(param[0]==1){
                param[0]=3
            }else if(param[0]==2){
                param[0]=2
            }else if(param[0]==3){
                param[0]=1
            }else{
                param[0]=0
            }


            if(param[1]==1){
                param[1]=5
            }else if(param[1]==2){
                param[1]=4
            }else if(param[1]==3){
                param[1]=3
            }else if(param[1]==4) {
                param[1] = 1
            }
            else{
                param[1]=0
            }



            if(param[2]==1){
                param[2]=5
            }else if(param[2]==2){
                param[2]=4
            }else if(param[2]==3){
                param[2]=3
            } else if(param[2]==4){
                param[2]=2
            } else if(param[2]==5){
                param[2]=0
            } else {
                param[2]=0
            }


            if (param[3] == 1) {
                param[3] = 3
            } else if (param[3] == 2) {
                param[3] = 2
            } else if(param[3] == 3){
                param[3] = 1
            }else{
                param[3] = 0
            }


            if(param[4]==1){
                param[4]=5
            }else if(param[4]==2){
                param[4]=4
            }else if(param[4]==3){
                param[4]=3
            } else if(param[4]==4){
                param[4]=2
            } else if(param[4]==5){
                param[4]=1
            }else if(param[4]==6){
                param[4]=0
            } else {
                param[4]=0
            }

            if(param[5]==1){
                param[5]=5
            }else if(param[5]==2){
                param[5]=4
            }else if(param[5]==3){
                param[5]=3
            } else if(param[5]==4){
                param[5]=2
            } else if(param[5]==5){
                param[5]=0
            }else if(param[5]==6){
                param[5]=0
            } else {
                param[5]=0
            }

            if(param[6]==1){
                param[6]=10
            }else if(param[6]==2){
                param[6]=8
            }else if(param[6]==3){
                param[6]=5
            } else if(param[6]==4){
                param[6]=0
            } else {
                param[6]=0
            }
            total= param[0]+param[1]+param[2]+param[3]+param[4]+param[5]+param[6];

            return total;
        };

        //担保信息
        $scope.messageCount4_2= function () {
            var total=0;
            var param=[
                Number($scope.ctrlScope.message_2.guarantee)
            ];


            if (!param[0]) {
                param[0] = 0;

            }

            if(param[0]==1){
                param[0]=30
            }else if(param[0]==2){
                param[0]=28
            }else if(param[0]==3){
                param[0]=25
            }else if(param[0]==4){
                param[0]=20
            }else if(param[0]==5){
                param[0]=15
            }else if(param[0]==6){
                param[0]=0
            }
            else{
                param[0]=0
            }
            total=param[0];
            return total;
        };

        //加分项
        $scope.messageCount5_2= function () {
                var total=0;
                var param=[
                    Number($scope.ctrlScope.message_2.addgrade)
                ];


                if (!param[0]) {
                    param[0] = 0;

                }

                if(param[0]==1){
                    param[0]=20
                }else if(param[0]==2){
                    param[0]=18
                }else if(param[0]==3){
                    param[0]=15
                }else if(param[0]==4){
                    param[0]=15
                }else if(param[0]==5){
                    param[0]=13
                }else if(param[0]==6){
                    param[0]=0
                }
                else{
                    param[0]=0
                }
                total=param[0];
                return total;
            };

        //总得分
        $scope.totalScore_2= function () {
            var totalScore=0;

            $scope.score={
                a_2:false,
                b_2:false,
                c_2:false,
                d_2:false,
                e_2:false
            };

            totalScore=$scope.messageCount1_2()+$scope.messageCount2_2()+$scope.messageCount3_2()+$scope.messageCount4_2()+$scope.messageCount5_2();
            if(totalScore > 90){
                $scope.score.a_2=true
            }else if(totalScore<=90 && totalScore>85){
                $scope.score.b_2=true
            }else if(totalScore<=85 && totalScore>75){
                $scope.score.c_2=true
            }else if(totalScore<=75 && totalScore>65){
                $scope.score.d_2=true
            }
            return totalScore
        }


    }]);


});